function Bullet() {
	this.init = function() {
		this.speed = 10;
		this.body = document.createElement("div");
		this.body.className = "bullet";
		new GameEngine().append(this);
		this.body.style.left = new MyPlane().left() + new MyPlane().width() / 2 - this.width() / 2 + "px";
		this.body.style.bottom = new MyPlane().height() + "px";
		return this;
	}
	this.left = function(){
		return this.body.offsetLeft;
	}
	this.top = function(){
		return this.body.offsetTop;
	}
	this.width = function() {
		return this.body.offsetWidth;
	}
	this.height = function() {
		return this.body.offsetHeight;
	}
	this.move = function() { //移动
		this.movetimer = setInterval(function() {
			this.body.style.bottom = parseInt(this.body.style.bottom) + this.speed + "px";
			if(this.body.offsetTop < -this.height()) {
				clearInterval(this.movetimer); //关闭运动的定时器
				this.destroy();
				return;
			}
			//子弹每移动一步，进行一次碰撞检测
			var enemes = new GameEngine().enemes;
			for(var en of enemes) {
				var leftside = this.left() > (en.left()-this.width());
				var rightside = this.left() < (en.left()+en.width());
				var topside = this.top() > (en.top()-this.height());
				var downside = this.top() < (en.top()+en.height());
				
				if( leftside && rightside && topside && downside ) {
					en.hurt(); //飞机受伤
					clearInterval(this.movetimer); //关闭运动的定时器
					this.explode(); //子弹爆炸
					break;
				}
			}
		}.bind(this), 30);
	}
	this.explode = function() { //爆炸
		this.body.className = "bullet_die";
		setTimeout(function(){
			this.body.style.background = "url(images/die2.png)";
			setTimeout(function(){
				this.destroy();
			}.bind(this),100);
		}.bind(this),100);
	}
	this.destroy = function() {
		this.body.remove();
	}
}